import request from '@/utils/request'
import { data } from 'jquery';
import qs from 'qs';

// 获取本地知识
const getLocalKnowledgeUrl = "/api/Home/GetLocalKnowledgeList"
export function getLocalKnowledge(data) {
    return request({
        url: getLocalKnowledgeUrl + "?id=" + data,
        method: "get"
    })
}

// 获取CNKI知识
const getCNKIUrl = "/api/Home/GetCNKIKnowledgeList"
export function getCNKI() {
    return request({
        url: getCNKIUrl,
        method: "get"
    })
}

// 初级检索
const searchUrl = "/api/Search/GetResultList"
export function getSearch(obj) {
    obj.type = Number(obj.type);
    obj.pagenow = Number(obj.pagenow);
    obj.pagesize = Number(obj.pagesize);
    return request({
        url: searchUrl + "?type=" + obj.type + "&pagenow=" + obj.pagenow + "&pagesize=" + obj.pagesize + "&wherestr=" + obj.wherestr + "&orderstr=" + obj.orderstr,
        method: "get"
    })
}

// 高级检索
const searchMoreUrl = "/api/Search/GetResultList"
export function getSearchMore(obj) {
    obj.type = Number(obj.type);
    obj.pagenow = Number(obj.pagenow);
    obj.pagesize = Number(obj.pagesize);
    return request({
        url: searchMoreUrl + "?type=" + obj.type + "&pagenow=" + obj.pagenow + "&pagesize=" + obj.pagesize + "&wherestr=" + obj.wherestr + "&orderstr=" + obj.orderstr,
        method: "get"
    })
}

// 单库检索
const singleSearchUrl = "/api/Search/SingleSearch"
export function singleSearch(obj) {
    obj.type = Number(obj.type);
    obj.pagenow = Number(obj.pagenow);
    obj.pagesize = Number(obj.pagesize);
    return request({
        url: singleSearchUrl + "?type=" + obj.type + "&pagenow=" + obj.pagenow + "&pagesize=" + obj.pagesize + "&wherestr=" + obj.wherestr + "&orderstr=" + obj.orderstr + "&dbcode=" + obj.dbcode,
        method: "get"
    })
}

// cnki详情
const cnkiDetailUrl = "/api/Search/GetCNKIDetial"
export function getCnkiDetail(obj) {
    return request({
        url: cnkiDetailUrl + "?dbcode=" + obj.dbcode + "&filename=" + obj.filename + "&dbname=" + obj.dbname,
        method: "get"
    })
}

// 本地知识详情
const localDetailUrl = "/api/Search/GetDetial"
export function getLocalDetail(obj) {
    return request({
        url: localDetailUrl + "?dbcode=" + obj.dbcode + "&sysid=" + obj.sysid,
        method: "get"
    })
}

// 点赞,踩 
const thumbUrl = "/api/Search/PostThumbUpOrDownUrl";
export function getThumb(data) {
    return request({
        url: thumbUrl,
        method: "post",
        data: qs.stringify(data),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
    })
}

// 点赞,踩 
const getThumbUrl = "/api/Search/GetZanOrCaiInfo";
export function getThumbVal(data) {
    return request({
        url: getThumbUrl + "?dbcode=" + data.dbcode + "&sysid=" + data.sysid + "&type=" + data.type,
        method: "get",
    })
}

// 收藏 
const collectUrl = "/api/Search/PostCollect";
export function getCollect(data) {
    return request({
        url: collectUrl,
        method: "post",
        data: qs.stringify(data),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
    })
}

// 获取人员列表
const peopleUrl = "/api/Search/GetUser";
export function getPeople() {
    return request({
        url: peopleUrl,
        method: "get",
    })
}

// 搜索人员
const searchPeopleUrl = "/api/Search/GetUserList";
export function searchPeople(data) {
    return request({
        url: searchPeopleUrl + "?username=" + data.username + "&pagenow=" + data.pagenow + "&pagesize=" + data.pagesize,
        method: "get",
    })
}

// 推荐给他人
const recommendUrl = "/api/Search/PostRecommend";
export function recommendPeople(data) {
    return request({
        url: recommendUrl,
        method: "post",
        data: qs.stringify(data),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
    })
}

// 获取pdf路径
const pdfUrl = "/api/Search/GetOnlineUrl";
export function getPdfUrl(data) {
    return request({
        url: pdfUrl + "?dbcode=" + data.dbcode + "&sysid=" + data.sysid,
        method: "get",
    })
}

// pdf预览之前进行userName传值
const browseInUrl = "/api/Search/insertPoint";
export function browseIn(data) {
    return request({
        url: browseInUrl + "?dbcode=" + data.dbcode + "&sysid=" + data.sysid + "&username=" + data.username,
        method: "get",
    })
}

// 获取列表内容集成接口
const homeUrl = "/api/Search/GetHome";
export function getHomeList(data) {
    return request({
        url: homeUrl + "?type=" + data.type + "&style=" + data.style + (data.code ? "&code=" + data.code : "") + (data.pagenow ? "&pagenow=" + data.pagenow + "&pagesize=" + data.pagesize : ""),
        method: "get"
    })
}


// 获取共享知识tab
const getKnowledgeTabUrl = "/api/Search/GetGXZSFenLei";
export function getKnowledgeTab() {
    return request({
        url: getKnowledgeTabUrl,
        method: "get",
    })
}

// 下载
const getDownUrl = "/api/Search/GetFileFromWebApi";
export function getDown(data) {
    return request({
        url: getDownUrl,
        method: "get",
        params: data,
    })
}

// 相似文献
const GetSimilarWenXianUrl = "/api/Search/GetSimilarWenXian";
export function GetSimilarWenXian(data) {
    return request({
        url: GetSimilarWenXianUrl,
        method: "get",
        params: data,
    })
}